package initialize

import (
	"fmt"
	"server/common"
	"server/internal/model"
	"server/utils"
)

func AutoMigrate(dst ...interface{}) {
	err := common.DB.AutoMigrate(dst...)
	if err != nil {
		fmt.Println(err.Error())
	}
}

func TnitTable() {
	AutoMigrate(model.User{})

	AutoMigrate(model.Project{})

	AutoMigrate(model.Task{})

	AutoMigrate(model.HisTask{})

	AutoMigrate(model.PipeLine{})

	AutoMigrate(model.HisPipe{})

	AutoMigrate(model.ToolMeau{}, model.Tool{})
	AutoMigrate(model.RestfulMeau{}, model.Restful{})

	AutoMigrate(model.Node{})
	AutoMigrate(model.Env{})

	AutoMigrate(model.Article{})

	AutoMigrate(model.TestCase{}, model.CaseMeau{})
	AutoMigrate(model.HisCase{})
	AutoMigrate(model.Log{})
	AutoMigrate(model.Fio{})
	user := &model.User{}
	user.Name = "admin"
	user.PassWord = utils.EncodeMD5("admin@123")
	user.Role = "superadmin"
	if err := user.Create(); err != nil {
		fmt.Println(err.Error())
	}
}
